import py_compile
py_compile.compile("Crazy_0.1.py")

import pygame
from pygame.locals import *
from sys import exit

import os

width, height = 640, 480

pygame.init()
screen = pygame.display.set_mode((width,height), 0, 32)
pygame.display.set_caption("Exemplo 2")

# Musica do jogo
pygame.mixer.music.load("musica" + os.sep + "Basshunter_Dota.mp3")
pygame.mixer.music.play(-1)
tocando = True;

image = pygame.image.load('imagem' + os.sep + "tetris2.jpg").convert()

img_width, img_height = image.get_size()

x, y = 0, 1; #posicao

varia_x, varia_y = 0.2, 0.2 #velocidade

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            exit()

    if y + img_height >= height or y <= 0:
        varia_y = -varia_y

    #x += varia_x
    y += varia_y
	
    # Movimenta o bloco
    pressed_keys = pygame.key.get_pressed()
	
    if pressed_keys[K_LEFT] and x > 0:
        x -= 1
    if pressed_keys[K_RIGHT] and x < height:
        x += 1
    
           
    screen.blit(image, (x, y))
    

    pygame.display.flip() # update()
